package com.ruoyi.information.controller.pc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.information.domain.pc.SysUserNeed;
import com.ruoyi.information.service.pc.ISysUserNeedService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 需求方Controller
 *
 * @author ruoyi
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/userNeed")
public class SysUserNeedController extends BaseController
{
    @Autowired
    private ISysUserNeedService sysUserNeedService;

    /**
     * 查询需求方列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysUserNeed sysUserNeed)
    {
        startPage();
        List<SysUserNeed> list = sysUserNeedService.selectSysUserNeedList(sysUserNeed);
        return getDataTable(list);
    }


    /**
     * 获取需求方详细信息
     */
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(sysUserNeedService.selectSysUserNeedByUserId(userId));
    }

    /**
     * 新增需求方
     */
    @PostMapping
    public AjaxResult add(@RequestBody SysUserNeed sysUserNeed)
    {
        return toAjax(sysUserNeedService.insertSysUserNeed(sysUserNeed));
    }

    /**
     * 修改需求方
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserNeed sysUserNeed)
    {
        return toAjax(sysUserNeedService.updateSysUserNeed(sysUserNeed));
    }

    /**
     * 删除需求方
     */
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysUserNeedService.deleteSysUserNeedByUserIds(userIds));
    }
}
